package com.gxa.meiye.admin.platform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.meiye.admin.platform.mapper.SettleMapper;
import com.gxa.meiye.admin.platform.pojo.domain.Shop;
import com.gxa.meiye.admin.platform.pojo.vo.SettleVo;
import com.gxa.meiye.admin.platform.service.SettleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SettleServiceImpl extends ServiceImpl<SettleMapper, SettleVo> implements SettleService {

    @Autowired
    private SettleMapper settleMapper;


    @Override
    public List<SettleVo> selectSettleList() {
        List<SettleVo> settleVos = settleMapper.selectSettleList();
        return settleVos;
    }

    @Override
    public void agree(Integer id) {
        settleMapper.audit(id,1);
    }

    @Override
    public void reject(Integer id) {
        settleMapper.audit(id,2);
    }

    @Override
    public List<SettleVo> selectSettles(String select) {
        LambdaQueryWrapper<SettleVo> settleVoLambdaQueryWrapper = Wrappers.lambdaQuery();
        settleVoLambdaQueryWrapper.like(SettleVo::getResponsiblePerson,"%"+select+"%")
                .or().like(SettleVo::getName,"%"+select+"%").or().like(SettleVo::getResponsiblePersonPhone,"%"+select+"%");
        return settleMapper.selectList(settleVoLambdaQueryWrapper);
    }

    @Override
    public Shop selectSettle(Integer id) {
        Shop shop = settleMapper.selectById(id);
        return shop;
    }
}
